cmake_minimum_required(VERSION 2.8)

project("Low-Level GPU Programming")
set(LOW_LEVEL_GPU_PROGRAMMING_VERSION_MAJOR 1)
set(LOW_LEVEL_GPU_PROGRAMMING_VERSION_MINOR 0)
set(LOW_LEVEL_GPU_PROGRAMMING_VERSION_PATCH 0)

# find SDL 1.3
find_path(SDL_INCLUDE_DIR SDL.h /usr/local/include/SDL "${CMAKE_SOURCE_DIR}/../SDL/include")
find_library(SDL_LIBRARY SDL "${CMAKE_SOURCE_DIR}/../SDL/lib/win32")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SDL DEFAULT_MSG SDL_INCLUDE_DIR SDL_LIBRARY)

# find CUDA
find_path(CUDA_INCLUDE_DIR cuda.h /usr/local/cuda/include "${CMAKE_SOURCE_DIR}/../CUDA/include")
find_library(CUDA_LIBRARY cuda "${CMAKE_SOURCE_DIR}/../CUDA/lib/win32")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(cuda DEFAULT_MSG CUDA_INCLUDE_DIR CUDA_LIBRARY)

if (UNIX)
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/../bin/linux")
endif (UNIX)

if (WIN32)
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/../bin")
endif (WIN32)

if (MSVC)
    add_definitions(-D_CRT_SECURE_NO_WARNINGS)
    add_definitions(-DOPENCTM_STATIC)
	add_definitions(-DTW_NO_LIB_PRAGMA)
    add_definitions(-DTW_STATIC)
    add_definitions(-DGLEW_STATIC)
endif (MSVC)

#if (UNIX)
#    set(CMAKE_CXX_FLAGS "-std=c++0x -g")
#endif (UNIX)

include_directories(
    "${SDL_INCLUDE_DIR}"
	"${CUDA_INCLUDE_DIR}"
    common
    external/GLEW/include
    external/stbi
    external/glm
    external/OpenCTM/include
    external/AntTweakBar/include)

add_subdirectory(external)
add_subdirectory(common)
add_subdirectory(samples)
